'''
Created on Aug 6, 2013

@author: Yuanpeng_Li
Write a method to replace all spaces in a string with '%20'
'''

def replace_space(string):
    result = []
    for c in string:
        if c == ' ':
            result.append('%20')
        else:
            result.append(c)
    return ''.join(result)

if __name__ == '__main__':
    print(replace_space("Hello World!"))